package guijavacommander.lister;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;

/**
 * User: Deady
 * Date: 20.07.2009
 * Time: 10:16:03
 */
public class ListerFrame extends JFrame {
    private ListerPanel panel;

    public ListerFrame()  {

        setSize(640, 480);
        //setDefaultCloseOperation(EXIT_ON_CLOSE);
        panel = new ListerPanel();

        panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
        panel.getActionMap().put("close", new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                ListerFrame.this.setVisible(false);
            }
        });

        getContentPane().add(panel);
    }

    public void setSource(File file) {
        panel.setSource(file);
        setTitle(file.getAbsolutePath());
    }


    public static void main(String[] args) {
        ListerFrame f = new ListerFrame();
        f.setSource(new File("/home/Deady/archive/programming/jdk/jdk-6-linux-i586-rpm.bin"));
        f.setVisible(true);
    }
}
